package cn.com.iresearch.android.componentizationsupporter


/**
 * 组件管理器
Created By: Seal.Wu
Date: 2018/4/3
Time: 10:21
 */
internal object ComponentManager {

    private val components = mutableMapOf<String, IComponent>()

    fun registerComponent(component: IComponent) {
        components.put(component.getComponentName(), component)
    }

    fun unRegisterComponent(component: IComponent) {
        components.remove(component.getComponentName())
    }

    fun getComponent(componentName: String): IComponent {
        return components.get(componentName) ?: EmptyComponent
    }

    fun getAllComponents(): List<IComponent> {
        return components.values.toList()
    }
}